﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
//导入命名空间
using System.Data.SqlClient; 

namespace T2task1
{
    class Program
    {
        static void Main(string[] args)
        {
            //创建数据库连接对象
            string connStr = "server=.;database=Game;Integrated Security=true";
            SqlConnection conn = new SqlConnection(connStr);
            //打开连接
            conn.Open();
            //判断
            if (conn.State == System.Data.ConnectionState.Open)
            {
                Console.WriteLine("连接成功！！！");
               
                //创建命令对象Command
                string sqlStr = "update Students set StuSorce='86'where StuName='高云云'";
                SqlCommand cmd = new SqlCommand(sqlStr, conn);
                //执行Select查询命令，循环获取处理DataReader中的数据
                //操作一：执行ExecuteNonQuery方法，对数据库进行更改
                int number = cmd.ExecuteNonQuery();
                if (number > 0)
                {
                    Console.WriteLine("更新成功！！！！");
                }
                else
                {
                    Console.WriteLine("更新失败！！！");
                }
                conn.Close();

            }
            else
            {
                Console.WriteLine("连接失败！！！");
            }
        }
    }
}
